﻿Imports System
Imports System.Data
Imports System.Text
Imports System.Data.SqlClient
Public Class Coneccion
    Public con As New SqlConnection(Cadena_Conexion)
    Private Function Cadena_Conexion()
        Try
            Dim sCadena As New StringBuilder("")
            If (con Is Nothing) Then

                'sCadena.Replace("data source=", "192.168.0.38")
                'sCadena.Replace("initial catalog=", "Bd_Asistencia")
                'sCadena.Replace("user id=", "sa")
                'sCadena.Replace("password=", "")


                sCadena.Append("Data Source=<SERVIDOR>;")
                sCadena.Append("Initial Catalog=<BASE>;")
                'sCadena.Append("user id=<USER>;")
                'sCadena.Append("password=<PASSWORD>;")
                sCadena.Append("Integrated Security=true;")
                'sCadena.Append("user id=sa;packet size=4096")
                sCadena.Replace("<SERVIDOR>", "(local)")
                sCadena.Replace("<BASE>", "Bd_Asistencia")
                'sCadena.Replace("<USER>", "JHONATAN-PC\JHONATAN")
                'sCadena.Replace("<PASSWORD>", "")
            End If
            Return sCadena.ToString()
        Catch ex As Exception
            Throw
        End Try
    End Function

    Sub Cerrar_Conexion()
        Try
            If (con.State = ConnectionState.Open) Then
                con.Close()
            End If
        Catch ex As Exception
            Throw
        End Try
    End Sub

    Sub Abrir_Conexion()
        Try
            If (con.State = ConnectionState.Closed) Then
                con.Open()
            End If
        Catch ex As Exception
            Throw
        End Try
    End Sub
End Class
